<?php

namespace app\controller;

use app\service\DelayOrderService;
use support\Request;
use support\Response;

class DelayOrderController
{
    private DelayOrderService $delayOrderService;

    public function __construct()
    {
        $this->delayOrderService = DelayOrderService::getInstance();
    }

    /**
     * 环节待确认统计
     * @param Request $request
     * @return Response
     */
    public function stepCategoryWaitConfirmCount(Request $request): Response
    {
        $param = $request->post()['param'];
        $projectId = $param['project_id'];
        $dateSearch = $param['date_search'] ?? [];
        $episodeId = $param['episode_id'] ?? '';
        $waitForMeToConfirm = $param['code'] ?? '';
        $userId = $request->getSaasUserId();
        $res = $this->delayOrderService->stepCategoryWaitConfirmCount($projectId,$episodeId,$userId, $waitForMeToConfirm,$dateSearch);
        return json(success_response('', $res));
    }

    /**
     * 延期单-按集-环节统计
     * @param Request $request
     * @return Response
     */
    public function getDelayOrderCount(Request $request) : Response
    {
        $param = $request->post()["param"];
        $projectId = $param['project_id'];
        $userId = $request->getSaasUserId();
        $result = $this->delayOrderService->getDelayOrderCount($projectId,$userId);

        return json(success_response('query success', $result));
    }
}
